import 'dart:io';

import 'package:flutter/material.dart';

import 'package:get/get.dart';
import 'package:flutter_widgets_pc/theme/kq_theme_manager.dart';
import 'package:flutter_widgets_pc/widgets/button/kq_outline_button.dart';

import '../../resources/kq_theme_colors.dart';

/// 底部按钮通栏
///
/// 白色背景，里面一个蓝色背景白色文字按钮，字号16
///O
/// @author 周卓
///O
class KqBottomButton extends StatelessWidget {
  /// 标题
  final String title;

  /// 背景颜色
  final Color? backgroundColor;

  /// 按钮背景颜色
  final Color? btnBgColor;

  /// 按钮文字颜色
  final Color? btnTextColor;

  /// 按钮背景颜色-置灰
  final Color? disableBtnBgColor;

  /// 点击回调
  final Function(bool disabled)? onTap;

  /// 置灰
  final bool disabled;

  //true 强制底部按照正常的高度 不考虑ios底部导航
  final bool isForce;

  const KqBottomButton(
      {Key? key,
      required this.title,
      this.backgroundColor = KqThemeColors.bgWhite,
      this.disableBtnBgColor,
      this.btnTextColor,
      this.btnBgColor,
      this.onTap,
      this.disabled = false,
      this.isForce = false})
      : super(key: key);

  const KqBottomButton.normal(
      {super.key,
      required this.title,
      this.backgroundColor = KqThemeColors.bgWhite,
      this.btnBgColor = KqThemeColors.bgF0,
      this.btnTextColor = KqThemeColors.text59,
      this.disableBtnBgColor = KqThemeColors.bgD8,
      this.onTap,
      this.disabled = false,
      this.isForce = false});

  @override
  Widget build(BuildContext context) {
    double bottom = 10;
    return Container(
        color: backgroundColor,
        width: context.width,
        padding: EdgeInsets.fromLTRB(16, 10, 16, bottom),
        child: KqOutlineButton(
          title: title,
          radius: 4,
          borderWidth: 0,
          verticalPadding: 14,
          borderColor: (btnBgColor ??
                  KqThemeManager.instance.getConfig().commonConfig.mainColor ??
                  KqThemeColors.bgBlue).withOpacity(disabled ? 0.45: 1.0),
          bgColor: (btnBgColor ??
              KqThemeManager.instance.getConfig().commonConfig.mainColor ??
              KqThemeColors.bgBlue).withOpacity(disabled ? 0.45: 1.0),
          fontSize: 16,
          textColor: btnTextColor ?? KqThemeColors.textWhite,
          onTap: () {
            if (onTap != null) {
              onTap!(disabled);
            }
          },
        ));
  }
}
